// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

namespace SnapObjects.Data
{
    public class ModelSqlCondition : ISqlWhere, ISqlHaving
    {
        internal ModelSqlCondition(ModelConditionType conditionType, SqlWhereAttribute whereAttribute)
        {
            this.RawCondition = whereAttribute.RawCondition;
            this.ConditionType = conditionType;
            this.Left = whereAttribute.Left;
            this.Operator = whereAttribute.Operator;
            this.Right = whereAttribute.Right;
            this.RawConditionDefined = whereAttribute.RawConditionDefined;
        }
        public string RawCondition { get; }

        public ModelConditionType ConditionType { get; }

        public string Left { get; }

        public SqlBinaryOperator Operator { get; }

        public string Right { get; }

        public bool RawConditionDefined { get; }

        public bool RightDefined => !System.String.IsNullOrWhiteSpace(this.Right);
    }
}
